package 优先算法.递归_搜索与回溯.综合案列.找出所有子集的异或总和再求和;

public class Main {
    public static void main(String[] args) {

    }
}
class Solution {
    int path;
    int sum;
    public int subsetXORSum(int[] nums) {
        dfs(nums,0);
        return sum;
    }

    private void dfs(int[] nums, int start) {
        sum += path;
        for(int i = start; i < nums.length;i++){
            path ^= nums[i];
            dfs(nums, i + 1);
            path ^= nums[i];
        }
    }
}